import React, { useEffect } from 'react';
import type { FormProps } from 'antd';
import { Button, Radio, Form, Input, Select, Divider, message } from 'antd';
import { useIntl, setLocale } from '@umijs/max';
import ZH from '../../../images/ZH.png';
import US from '../../../images/US.png';
const Frist = () => {
 const [form] = Form.useForm();
   const intl = useIntl();
      const onFinish: FormProps['onFinish'] = (values) => {
        console.log('Success:', values);
        message.success(intl.formatMessage({ id: 'pages.login.Registration' }));
    
        setTimeout(() => {
        //   setIsRegister(true);
        }, 1500);
      };
    
      const onFinishFailed: FormProps['onFinishFailed'] = (errorInfo) => {
        console.log('Failed:', errorInfo);
      };
    
      const onChange = (value: string) => {
        console.log('change', value);
        form.setFieldValue('language', value);
        setLocale(value, false);
        localStorage.setItem('umi_locale', value);
      };
    
  return (
    <div>
       <Form
                name="basic"
                labelCol={{ span: 8 }}
                wrapperCol={{ span: 16 }}
                style={{ minWidth: 450 }}
                onFinish={onFinish}
                onFinishFailed={onFinishFailed}
                autoComplete="off"
                form={form}
              >
 <Form.Item
            label={intl.formatMessage({ id: 'pages.login.language' })}
            name="language"
            rules={[{ required: true, message: 'Please input your language!' }]}
            initialValue={'zh-CN'}
          >
            <Radio.Group onChange={(e) => onChange(e.target.value)}>
              <Radio value="zh-CN">
                <img style={{ width: 40, height: 25, borderRadius: 1 }} src={ZH} alt="" />
                &nbsp; 简体中文
              </Radio>
              <Radio value="en-US">
                <img style={{ width: 40, height: 25, borderRadius: 1 }} src={US} alt="" />
                &nbsp; English
              </Radio>
            </Radio.Group>
          </Form.Item>


              </Form>
    </div>
  )
}

export default Frist
